using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace InfiniTec.Data
{
    internal class PropertyValueCollection<T> : Collection<T>
    {
        private readonly Property _Property;

        public PropertyValueCollection(Property property)
        {
            _Property = property;
        }

        public void AddRange(IEnumerable<T> values)
        {
            foreach (T value in values)
            {
                Add(value);
            }
        }

        protected override void InsertItem(int index, T item)
        {
            base.InsertItem(index, item);
            _Property.SetChanged();
        }

        protected override void RemoveItem(int index)
        {
            base.RemoveItem(index);
            _Property.SetChanged();
        }

        protected override void ClearItems()
        {
            base.ClearItems();
            _Property.SetChanged();
        }

        protected override void SetItem(int index, T item)
        {
            base.SetItem(index, item);
            _Property.SetChanged();
        }
    }
}